<?php
/**
 * Model        系统核心
 * @copyright   Copyright(c) 2024-2034
 * @author      tianjie <527707665@qq.com>
 * @link        http://www.tinphp.com/
 * @version     4.1
 */

namespace tian\Medoo;

use Medoo\Medoo;

/**
 * Model        数据库操作类
 * @copyright   Copyright(c) 2015
 * @author      tianjie
 * @version     2.1
 **/
class Model extends Medoo
{
    //构造函数
    public function __construct($options = [])
    {
        if (empty($options)) {
            $database = config('database');
            if ($database['is_open']) {
                if (strtoupper($database['type']) == strtoupper('Medoo')) {
                    $configDb = $database['connections'][$database['default']];
                    $options = [
                        'type' => $configDb['type'],
                        'host' => $configDb['host'],
                        'database' => $configDb['database'],
                        'username' => $configDb['username'],
                        'password' => $configDb['password'],

                        'charset' => $configDb['charset'],
                        'port' => $configDb['port'],
                        'prefix' => $configDb['prefix'],

                    ];
                } else {
                    //其他模板引擎
                    echo "数据库 驱动 非 Medoo 引擎。";
                    exit();
                }
            } else {
                echo "数据库引擎 is_open 未开启。";
                exit();
            }
        }
        parent::__construct($options);
    }

}